Skip to content

Support bundled Gemini CLI layout for OAuth credential extraction#728

Closed
icey-zhang wants to merge 1 commit intosteipete:mainfrom
icey-zhang:fix/gemini-bundled-oauth-detection
Closed

Support bundled Gemini CLI layout for OAuth credential extraction#728
icey-zhang wants to merge 1 commit intosteipete:mainfrom
icey-zhang:fix/gemini-bundled-oauth-detection

Conversation

@icey-zhang
Copy link
Copy Markdown

Summary

  • Newer versions of Gemini CLI (installed via npm) use a bundled format where all code is packed into bundle/chunk-*.js files instead of the traditional dist/src/code_assist/oauth2.js path
  • This caused token refresh to fail with "Could not find Gemini CLI OAuth configuration" because none of the existing search paths matched
  • Add searchBundleDirectory fallback that scans chunk-*.js files in the bundle directory for embedded OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET

Test plan

  • All 39 GeminiStatusProbe tests pass
  • Manual verification: Gemini quota displays correctly after rebuild with bundled Gemini CLI (~/.nvm/.../gemini-cli/bundle/chunk-*.js layout)

🤖 Generated with Claude Code

Newer versions of Gemini CLI (installed via npm) use a bundled format
where all code is packed into `bundle/chunk-*.js` files instead of the
traditional `dist/src/code_assist/oauth2.js` path. This caused token
refresh to fail with "Could not find Gemini CLI OAuth configuration".

Add `searchBundleDirectory` as a fallback that scans `chunk-*.js` files
for embedded OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ratulsarna
Copy link
Copy Markdown
Collaborator

Thanks for catching and fixing the bundled Gemini CLI layout issue, @icey-zhang. This was a real compatibility gap.

Since this PR was opened, has gained a broader Gemini CLI package-root discovery path that handles the bundled layout by walking from through its relative imports and parsing the OAuth constants from the imported bundle chunks. I also re-checked the current published package shape, and that newer path covers the same layout this PR targets.

I’m going to close this one as superseded so the queue stays tidy, but thank you again for the sharp report and patch.

@ratulsarna ratulsarna closed this Apr 27, 2026
@ratulsarna
Copy link
Copy Markdown
Collaborator

Small correction: the inline code names were stripped from my previous comment by the shell. The intended details were: current main walks from bundle/gemini.js, parses its relative imports, and covers the current @google/gemini-cli bundle/chunk-*.js layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants